package io.renren.modules.sp.controller;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.fastjson.JSONArray;
import io.renren.common.annotation.LogOperation;
import io.renren.common.constant.Constant;
import io.renren.common.listener.SpStudentCerImportListener;
import io.renren.common.listener.SpImportMatchScoreListener;
import io.renren.common.listener.SpTeacherCerImportListener;
import io.renren.common.page.PageData;
import io.renren.common.redis.RedisUtils;
import io.renren.common.utils.DateUtils;
import io.renren.common.utils.ExcelUtils;
import io.renren.common.utils.Result;
import io.renren.common.validator.AssertUtils;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.security.user.UserDetail;
import io.renren.modules.sp.dto.*;
import io.renren.modules.sp.excel.*;
import io.renren.modules.sp.service.SpMatchItemService;
import io.renren.modules.sp.service.SpTeacherCerImportService;
import io.renren.modules.sp.service.SpMatchItemImportService;
import io.renren.modules.sp.service.SpMatchItemTeamService;
import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import java.util.*;


/**
* 参赛队
*
* @author whc 15953295779@126.com
* @since 3.0 2023-04-21
*/
@RestController
@RequestMapping("sp/spmatchitemteam")
@Api(tags="参赛队")
public class SpMatchItemTeamController {
    @Autowired
    private SpMatchItemImportService spMatchItemImportService;
    @Autowired
    private SpMatchItemTeamService spMatchItemTeamService;
    @Autowired
    private SpTeacherCerImportService spTeacherCerImportService;
    @Autowired
    private SysUserService sysUserService;
    @Autowired
    private SpMatchItemService spMatchItemService;
    @Autowired
    RedisUtils redisUtils;

    @GetMapping("page")
    @ApiOperation("分页")
    @ApiImplicitParams({
        @ApiImplicitParam(name = Constant.PAGE, value = "当前页码，从1开始", paramType = "query", required = true, dataType="int") ,
        @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
        @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
        @ApiImplicitParam(name = Constant.ORDER, value = "排序方式，可选值(asc、desc)", paramType = "query", dataType="String")
    })
    @RequiresPermissions("sp:spmatchitemteam:page")
    public Result<PageData<SpMatchItemTeamDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
        PageData<SpMatchItemTeamDTO> page = spMatchItemTeamService.page(params);

        return new Result<PageData<SpMatchItemTeamDTO>>().ok(page);
    }

    @GetMapping("{id}")
    @ApiOperation("信息")
    @RequiresPermissions("sp:spmatchitemteam:info")
    public Result<SpMatchItemTeamDTO> get(@PathVariable("id") Long id){
        SpMatchItemTeamDTO data = spMatchItemTeamService.get(id);

        return new Result<SpMatchItemTeamDTO>().ok(data);
    }

    @PostMapping
    @ApiOperation("保存")
    @LogOperation("保存")
    @RequiresPermissions("sp:spmatchitemteam:save")
    public Result save(@RequestBody SpMatchItemTeamDTO dto){
        //效验数据
        ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);

        spMatchItemTeamService.save(dto);

        return new Result();
    }

    @PutMapping
    @ApiOperation("修改")
    @LogOperation("修改")
    @RequiresPermissions("sp:spmatchitemteam:update")
    public Result update(@RequestBody SpMatchItemTeamDTO dto){
        //效验数据
        ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);

        spMatchItemTeamService.update(dto);

        return new Result();
    }

    @DeleteMapping
    @ApiOperation("删除")
    @LogOperation("删除")
    @RequiresPermissions("sp:spmatchitemteam:delete")
    public Result delete(@RequestBody Long[] ids){
        //效验数据
        AssertUtils.isArrayEmpty(ids, "id");

        spMatchItemTeamService.delMatchItemTeam(ids);

        return new Result();
    }

    /**
     * 修改条目状态，把弃权的修改成报名成功
     * @param params
     * @return
     */
    @PostMapping("updateStatus")
    @ApiOperation("修改条目状态")
    @LogOperation("修改条目状态")
    @RequiresPermissions("sp:spmatchitemteam:updateStatus")
    public Result updateStatus(@RequestBody Map<String, Object> params){
        //效验数据
        AssertUtils.isNull(params.get("id"), "id");
        AssertUtils.isNull(params.get("status"), "status");
        spMatchItemTeamService.updateStatus(Long.parseLong(params.get("id").toString()), Integer.parseInt(params.get("status").toString()));
        return new Result();
    }

    @GetMapping("matchScoreRecord")
    public Result<PageData<Map>> matchScoreRecord(@ApiIgnore @RequestParam Map<String, Object> params){

        PageData<Map> page = spMatchItemTeamService.matchScoreRecord(params);

        return new Result<PageData<Map>>().ok(page);
    }

    @GetMapping("exportSignRecord")
    @ApiOperation("导出")
    @LogOperation("导出")
    @RequiresPermissions("sp:spmatchitemteam:export")
    public void exportSignRecord(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
        UserDetail user = (UserDetail) SecurityUtils.getSubject().getPrincipal();
        //判断是否是赛项管理员
        String userType = sysUserService.getSysUserType();
        if("2".equals(userType)){
            // 查询所管理赛项
            Map<String, Object> p = new HashMap<>();
            p.put("adminId", user.getId());
            List<SpMatchItemDTO> list = spMatchItemService.list(p);
            //查询赛项id集合
            String ids = "";
            for(SpMatchItemDTO dto : list){
                if(dto.getId() != null){
                    ids += dto.getId() + ",";
                }
            }
            if(ids.contains(",")){
                ids = ids.substring(0, ids.length() - 1);
                params.put("userMatchItemId", ids);
            }
        }
        params.put("page", "1");
        params.put("limit", "20000");
        PageData<Map> page = spMatchItemTeamService.signRecord(params);
        this.exportSignRecordRise(params, page, SpSignListExcel.class, response);
    }

    @GetMapping("exportSignRecordRise")
    @ApiOperation("导出")
    @LogOperation("导出")
    @RequiresPermissions("sp:spmatchitemteam:export")
    public void exportSignRecordRise(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
        params.put("page", "1");
        params.put("limit", "20000");
        PageData<Map> page = spMatchItemTeamService.signRecordRise(params);
        this.exportSignRecordRise(params, page, SpSignListExcel.class, response);
    }

    public void exportSignRecordRise(Map<String, Object> params,PageData<Map> page, Class<?> className, HttpServletResponse response) throws Exception {
        List<Map> list = page.getList();
        List<SpSignListExcel> listExcel = new ArrayList<>();
        SpSignListExcel excel = null;
        String fileName = "";
        for (Map map : list) {
            excel = new SpSignListExcel();
            //代表队名称 队伍名称 组别 选手 状态 选手编号 选手单位 指导老师
            excel.setId((Long) map.get("id") + "");
            excel.setMatchName((String) map.get("matchName"));
            excel.setItem((String) map.get("item"));
            excel.setTeamName((String) map.get("teamName"));
            excel.setGroupName((String) map.get("groupName"));
            excel.setDictLabel((String) map.get("dictLabel"));
            excel.setRealName((String) map.get("realName"));
            excel.setLeaderName((String) map.get("leaderName"));
            excel.setPhone((String) map.get("phone"));
            int status = (Integer) map.get("status");
            int isRise = (Integer) map.get("isRise");
            String rejectReason = (String) map.get("rejectReason");
            //0审核中 1报名成功 2完赛 3已取消 4比赛中 5已获晋级资格 6晋级成功 7弃权 8驳回 9待确认 10报名未成功
            if (status == 0) {
                excel.setStatus("审核中");
            } else if (status == 1) {
                excel.setStatus("报名成功");
            } else if (status == 2) {
                if (isRise == 1) {
                    excel.setStatus("已确认晋级");
                } else {
                    excel.setStatus("完赛");
                }
            } else if (status == 4) {
                excel.setStatus("比赛中");
            } else if (status == 5) {
                if("放弃晋级".equals(rejectReason)) {
                    excel.setStatus("放弃晋级");
                }else{
                    excel.setStatus("已获晋级资格");
                }
            } else if (status == 6) {
                excel.setStatus("晋级成功");
            } else if (status == 7) {
                excel.setStatus("弃权");
            } else if (status == 8) {
                excel.setStatus("驳回");
            } else if (status == 9) {
                excel.setStatus("待确认");
            } else if (status == 10) {
                excel.setStatus("报名未成功");
            }
            excel.setTicket((String) map.get("ticket"));
            excel.setCompany((String) map.get("userCompany"));
            excel.setTeacher((String) map.get("teacher"));
            listExcel.add(excel);

            fileName = map.get("matchName") + "";
        }
        String itemName  = (String)params.get("item");
        if(StringUtils.isNotBlank(itemName)){
            fileName += "-" + itemName;
        }else{
            fileName += "-全部";
        }
        fileName += "-" + DateUtils.format(new Date(), "YYYYMMdd");
        fileName += "-" + list.size();
        ExcelUtils.exportExcelToTarget(response, fileName, "报名记录", listExcel, className); //SpSignListExcel.class
    }

    @GetMapping("export")
    @ApiOperation("导出")
    @LogOperation("导出")
    @RequiresPermissions("sp:spmatchitemteam:export")
    public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
        params.put("page", "1");
        params.put("limit", "20000");
        PageData<Map> page = spMatchItemTeamService.matchScoreRecord(params);
        List<Map> list = page.getList();
        List<SpSignRecordExcel> listExcel = new ArrayList<>();
        SpSignRecordExcel excel = null;
        for(Map map : list){
            excel = new SpSignRecordExcel();
            //teamName realName realName company score1 score2 ranks jiangdeng bianhao status
            excel.setId((Long)map.get("id")+"");
            excel.setTeamName((String)map.get("teamName"));
            excel.setRealName((String)map.get("realName"));
            excel.setTicket((String)map.get("ticket"));
            //excel.setCompany((String)map.get("company"));
            excel.setScore1((String)map.get("score1"));
            excel.setScore2((String)map.get("score2"));
            excel.setRanks((Integer)map.get("ranks")+"");
            excel.setGrade((String)map.get("grade"));
            listExcel.add(excel);
        }
        ExcelUtils.exportExcelToTarget(response, null, "赛事成绩", listExcel, SpSignRecordExcel.class);
    }


    @PostMapping("rise")
    @ApiOperation("推荐晋级")
    @LogOperation("推荐晋级")
    //@RequiresPermissions("sp:spmatchitemteam:rise")
    public Result rise(@RequestBody Map<String, Object> params){
        String id = (String)params.get("id");
        String status = (String)params.get("status");
        spMatchItemTeamService.rise(new Long[]{Long.parseLong(id)}, Integer.parseInt(status));
        return new Result();
    }

    /**
     * 重置成完赛
     */
    @GetMapping("cancleRise")
    @LogOperation("重置成完赛")
    public Result cancleRise(@RequestParam Long id){
        return spMatchItemTeamService.cancleRise(id);
    }

    //报名记录
    @GetMapping("signRecord")
    public Result<PageData<Map>> signRecord(@ApiIgnore @RequestParam Map<String, Object> params){
        UserDetail user = (UserDetail) SecurityUtils.getSubject().getPrincipal();
        //判断是否是赛项管理员
        String userType = sysUserService.getSysUserType();
        if("2".equals(userType)){
            // 查询所管理赛项
            Map<String, Object> p = new HashMap<>();
            p.put("adminId", user.getId());
            List<SpMatchItemDTO> list = spMatchItemService.list(p);
            //查询赛项id集合
            String ids = "";
            for(SpMatchItemDTO dto : list){
                if(dto.getId() != null){
                    ids += dto.getId() + ",";
                }
            }
            if(ids.contains(",")){
                ids = ids.substring(0, ids.length() - 1);
                params.put("userMatchItemId", ids);
            }

        }
        PageData<Map> page = spMatchItemTeamService.signRecord(params);
        return new Result<PageData<Map>>().ok(page);
    }

    //报名记录-已获晋级资格
    @GetMapping("signRecordRise")
    public Result<PageData<Map>> signRecordRise(@ApiIgnore @RequestParam Map<String, Object> params){
        PageData<Map> page = spMatchItemTeamService.signRecordRise(params);
        return new Result<PageData<Map>>().ok(page);
    }

    @PostMapping("pass")
    @ApiOperation("审核")
    @LogOperation("审核")
    public Result pass(@RequestBody Map<String, Object> params){
        String id = (String)params.get("id");
        String status = (String)params.get("status");
        String rejectReason =
                params.get("rejectReason") == null ? "" : (String)params.get("rejectReason");
        return spMatchItemTeamService.pass(new Long[]{Long.parseLong(id)}, Integer.parseInt(status),rejectReason);
    }

    @PostMapping("passBatch")
    @ApiOperation("审核")
    @LogOperation("审核")
    public Result passBatch(@RequestBody Long[] ids){
        for (Long id : ids) {
            spMatchItemTeamService.pass(new Long[]{id}, 1,null);
        }
        return new Result();
    }

    /**
     * 弃权
     * @return
     */
    @PostMapping("cancel")
    @LogOperation("弃权")
    public Result cancel(@RequestBody  SpMatchItemTeamDTO dto){
        return spMatchItemTeamService.cancel(dto);
    }

    //报名记录
    @GetMapping("groupCount")
    public Result<PageData<Map>> groupCount(@ApiIgnore @RequestParam Map<String, Object> params){

        PageData<Map> page = spMatchItemTeamService.groupCount(params);

        return new Result<PageData<Map>>().ok(page);
    }

    /**
     * 导入获奖证书：第一步
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("importCertificate")
    @ApiImplicitParam(name = "file", value = "文件", paramType = "query", dataType="file")
    @LogOperation("导入获奖证书")
    public Result importCertificate(@RequestParam("file") MultipartFile file) throws Exception {
        Result result = new Result();
        List<SpCertificateImport> list = new ArrayList<>();
        //大批量excel数据导入
        EasyExcel.read(file.getInputStream(), SpCertificateImport.class,
                new SpStudentCerImportListener(spMatchItemImportService,result, list)).sheet().doRead();
        for(SpCertificateImport spCertificateImport : list){
            if(StringUtils.isNotEmpty(spCertificateImport.getCheckMsg())) {
                String errorCode = UUID.randomUUID().toString();
                redisUtils.set(errorCode, JSONArray.toJSONString(list), 1000);
                return new Result().ok(errorCode);
            }
        }
        return result;
    }

    /**
     * 导入获奖证书：第二步 出错后触发下载错误
     * @param errorCode
     * @param response
     * @throws Exception
     */
    @GetMapping("exportCertificateError")
    @ApiOperation("导出")
    @LogOperation("获奖证书导出错误消息")
    public void exportCertificateError(String errorCode,HttpServletResponse response) throws Exception {
        String json = (String) redisUtils.get(errorCode);
        redisUtils.delete(errorCode);
        if (json != null) {
            List<SpCertificateExport> list = JSONArray.parseArray(json, SpCertificateExport.class);
            ExcelUtils.exportExcelToTarget(response, "失败原因", "失败证书", list, SpCertificateExport.class);
        }
    }


    /**
     * 导入指导老师获奖证书：第一步
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("importCertificateTeacher")
    @ApiImplicitParam(name = "file", value = "文件", paramType = "query", dataType="file")
    @LogOperation("导入指导老师获奖证书")
    public Result importCertificateTeacher(@RequestParam("file") MultipartFile file) throws Exception {
        Result result = new Result();
        List<SpTeacherCerImport> list = new ArrayList<>();
        //大批量excel数据导入
        EasyExcel.read(
                file.getInputStream(),
                SpTeacherCerImport.class,
                new SpTeacherCerImportListener(spTeacherCerImportService, result, list)
        ).sheet().doRead();
        for (SpTeacherCerImport spCerTeacherImport : list) {
            if (StringUtils.isNotEmpty(spCerTeacherImport.getCheckMsg())) {
                String errorCode = UUID.randomUUID().toString();
                redisUtils.set(errorCode, JSONArray.toJSONString(list), 1000);
                return new Result().ok(errorCode);
            }
        }
        return result;
    }

    /**
     * 导入指导老师获奖证书：第二步 出错后触发下载错误
     * @param errorCode
     * @param response
     * @throws Exception
     */
    @GetMapping("exportCertificateTeacherError")
    @ApiOperation("导出")
    @LogOperation("导入指导老师获奖证书：第二步")
    public void exportCertificateTeacherError(String errorCode,HttpServletResponse response) throws Exception {
        String json = (String) redisUtils.get(errorCode);
        redisUtils.delete(errorCode);
        if (json != null) {
            List<SpTeacherCerExport> list = JSONArray.parseArray(json, SpTeacherCerExport.class);
            ExcelUtils.exportExcelToTarget(response, "失败原因", "失败证书", list, SpTeacherCerExport.class);
        }
    }

    @PostMapping("importScore")
    @ApiImplicitParam(name = "file", value = "文件", paramType = "query", dataType="file")
    @LogOperation("导入成绩")
    public Result importExcel(@RequestParam("file") MultipartFile file, @RequestParam("matchId") String matchId) throws Exception {
        //解析并保存到数据库
        EasyExcel.read(file.getInputStream(), SpMatchItemTeamImport.class, new AnalysisEventListener<SpMatchItemTeamImport>() {
            List<SpMatchItemTeamImport> list = new ArrayList<>();
            @Override
            public void invoke(SpMatchItemTeamImport data, AnalysisContext context) {
                list.add(data);
                // 处理每一行数据
                System.out.println("读取到数据：" + data);
                // 在这里可以对数据进行进一步处理，例如保存到数据库等
            }
            @Override
            public void doAfterAllAnalysed(AnalysisContext context) {
                // 数据读取完成后的处理
                System.out.println("数据读取完成");
                spMatchItemImportService.importScore(list, matchId);
            }
        }).sheet().doRead();
         return new Result();
    }

    /**
     * 个人赛、团体赛导入
     * @param file
     * @param matchId
     * @return
     * @throws Exception
     */
    @PostMapping("importPormotion")
    @ApiImplicitParam(name = "file", value = "文件", paramType = "query", dataType="file")
    @LogOperation("导入晋级")
    public Result importPormotion(@RequestParam("file") MultipartFile file, @RequestParam("matchId") String matchId) throws Exception {
        final String[] error = {""};
        List<SpMatchItemTeamImport> list = new ArrayList<>();

        //解析并保存到数据库
        EasyExcel.read(file.getInputStream(), SpMatchItemTeamImport.class, new AnalysisEventListener<SpMatchItemTeamImport>() {
            @Override
            public void invoke(SpMatchItemTeamImport data, AnalysisContext context) {
                list.add(data);
                // 处理每一行数据
                System.out.println("读取到数据：" + data);
                // 在这里可以对数据进行进一步处理，例如保存到数据库等
            }
            @Override
            public void doAfterAllAnalysed(AnalysisContext context) {
                // 数据读取完成后的处理
                System.out.println("数据读取完成");
                try{
                    error[0] =spMatchItemImportService.importPormotion(list, matchId);

                }catch (Exception e){
                    error[0] =e.getMessage();
                }
            }
        }).sheet().doRead();
        if(StringUtils.isNotBlank(error[0])){
            String errorCode = UUID.randomUUID().toString();
            redisUtils.set(errorCode,JSONArray.toJSONString(list),1000);
            return new Result().ok(errorCode);
        }

        return new Result();
    }
    @GetMapping("exportError1")
    @ApiOperation("导出")
    @LogOperation("导出exportError1")
    public void export1(String errorCode,HttpServletResponse response) throws Exception {
        String json = (String) redisUtils.get(errorCode);
        redisUtils.delete(errorCode);
        if (json != null) {
            List<SpMatchItemTeamImport> list = JSONArray.parseArray(json, SpMatchItemTeamImport.class);
            List<SpMatchItemTeamSingleImport> listSingle = new ArrayList<>();
            List<SpMatchItemTeamIGroupmport> listGroup = new ArrayList<>();
            //是不是个人比赛
            boolean isSigle = true;
            //如果有组名说明是团体赛
            if(list.size()>0&&StringUtils.isNotBlank(list.get(0).getTeamName())){
                isSigle = false;
            }
            if(isSigle){
                for (SpMatchItemTeamImport item : list) {
                    SpMatchItemTeamSingleImport itemSingle = new SpMatchItemTeamSingleImport();
                    BeanUtil.copyProperties(item,itemSingle);
                    listSingle.add(itemSingle);
                }
                ExcelUtils.exportExcelToTarget(response, "失败原因", "晋级比赛", listSingle, SpMatchItemTeamSingleImport.class);

            }else{
                for (SpMatchItemTeamImport item : list) {
                    SpMatchItemTeamIGroupmport itemSingle = new SpMatchItemTeamIGroupmport();
                    BeanUtil.copyProperties(item,itemSingle);
                    listGroup.add(itemSingle);
                }
                ExcelUtils.exportExcelToTarget(response, "失败原因", "晋级比赛", listGroup, SpMatchItemTeamIGroupmport.class);

            }

            // 此处要要区分个人晋级和团队晋级，因为导出的字段不一样
            // todo
        }
    }
    @GetMapping("exportError2")
    @ApiOperation("导出")
    @LogOperation("导出exportError2")
    public void export2(String errorCode,HttpServletResponse response) throws Exception {
        String json =(String) redisUtils.get(errorCode);
        if(json !=null ){
            List<SpMatchItemTeamImport> list = JSONArray.parseArray(json,SpMatchItemTeamImport.class);
            ExcelUtils.exportExcelToTarget(response, null, "晋级比赛", list, SpMatchItemTeamImport.class);
        }
    }
    @PostMapping("importPormotionTeam")
    @ApiImplicitParam(name = "file", value = "文件", paramType = "query", dataType="file")
    @LogOperation("导入团队晋级")
    public Result importPormotionTeam(@RequestParam("file") MultipartFile file) throws Exception {
        //解析并保存到数据库
        EasyExcel.read(file.getInputStream(), SpMatchItemTeamImport.class, new AnalysisEventListener<SpMatchItemTeamImport>() {
            @Override
            public void invoke(SpMatchItemTeamImport data, AnalysisContext context) {
                // 处理每一行数据
                System.out.println("读取到数据：" + data);
                // 在这里可以对数据进行进一步处理，例如保存到数据库等
            }
            @Override
            public void doAfterAllAnalysed(AnalysisContext context) {
                // 数据读取完成后的处理
                System.out.println("数据读取完成");
            }
        }).sheet().doRead();

        return new Result();
    }


    /**
     * 导入证书-赛事成绩导入
     * spmatchitemrecord.vue
     *
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("importMatchScore")
    @ApiImplicitParam(name = "file", value = "文件", paramType = "query", dataType="file")
    @LogOperation("导入赛事成绩")
    public Result importMatchScore(@RequestParam("file") MultipartFile file, @RequestParam("matchItemId") String matchItemId) throws Exception {
        System.out.println(matchItemId);
        Result result = new Result();
        //大批量excel数据导入
        EasyExcel.read(file.getInputStream(), SpSignRecordExcel.class,
                new SpImportMatchScoreListener(spMatchItemImportService,result, redisUtils, Integer.parseInt(matchItemId))).sheet().doRead();
        if(result.getCode()!=0){
            return new Result().ok(result.getMsg());
        }
        return result;
    }

    @GetMapping("exportMatchScoreError")
    @ApiOperation("导出")
    @LogOperation("导出exportMatchScoreError")
    public void exportMatchScoreError(String errorCode,HttpServletResponse response) throws Exception {
        String json =(String) redisUtils.get(errorCode);
        if(json !=null ){
            List<SpSignRecordExcel> list = JSONArray.parseArray(json,SpSignRecordExcel.class);
            ExcelUtils.exportExcelToTarget(response, null, "成绩错误信息", list, SpSignRecordExcel.class);
        }
    }

    /**
     * 后台生成证书图片
     * @param params
     * @return
     */
    @GetMapping("certificate")
    @LogOperation("后台生成证书图片")
    public Result certificate(@RequestParam Map<String, Object> params){
        spMatchItemTeamService.certificate(params);
        return new Result().ok("生成成功");
    }

    /**
     * 按照赛事生成
     * @param params
     * @return
     */
    @GetMapping("certificateAll")
    public Result certificateAll(@RequestParam Map<String, Object> params){
        String matchId = (String)params.get("matchId");
        String[] ids = new String[]{"73","92","89","71","81","68","88","86"};
        for(String id : ids){
            List<Map<String,Object>> list = spMatchItemTeamService.queryAllItemGroup(Long.parseLong(id));
            Map<String, Object> paramsNew = new HashMap<>();
            for(Map<String,Object> map : list){
                paramsNew = new HashMap<>();
                paramsNew.put("groupId", map.get("group_id") + "");
                paramsNew.put("matchItemId", map.get("match_item_id") + "");
                spMatchItemTeamService.certificate(paramsNew);
            }
        }
        return new Result<>().ok(null);
    }

    /**
     * 单个荣誉编号生成
     * @param params
     * @return
     */
    @GetMapping("certificateOne")
    @LogOperation("单个荣誉编号生成")
    public Result certificateOne(@RequestParam Map<String, Object> params){
        spMatchItemTeamService.createCertificateNo(params);
        return new Result().ok("生成成功");
    }

    /**
     * 后台删除证书
     * @param id
     * @return
     */
    @GetMapping("delCertificate")
    @LogOperation("删除证书")
    public Result delCertificate(@RequestParam String id){
        String ids[] = id.split(",");
        for(String _id : ids) {
            spMatchItemTeamService.delCertificate(_id);
        }
        return new Result().ok("生成成功");

    }

    /**
     * 后台删除证书编号
     * @param id
     * @return
     */
    @GetMapping("cancelCertificateNo")
    @LogOperation("删除证书编号")
    public Result cancelCertificateNo(@RequestParam String id){
        String ids[] = id.split(",");
        for(String _id : ids) {
            spMatchItemTeamService.cancelCertificateNo(_id);
        }
        return new Result().ok("删除证书编号成功");
    }

    /**
     * 后台下载荣誉证书
     * @param params
     * @param response
     * @return
     * @throws Exception
     */
    @GetMapping("downloadCertificate")
    @LogOperation("下载荣誉证书")
    public Result<String> downloadCertificate(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception{
        return spMatchItemTeamService.downloadCertificate(params,response);
    }

    /**
     * 生成选手荣誉证书编号
     * @param params
     * @param
     * @return
     * @throws Exception
     */
    @GetMapping("createCertificateNo")
    @LogOperation("生成选手荣誉证书编号")
    public Result<List<Map<String,Object>>> createCertificateNo(@ApiIgnore @RequestParam Map<String, Object> params) throws Exception {
        Map<String, Object> result = spMatchItemTeamService.createCertificateNo(params);
        int code = (Integer) result.get("code");
        if (code == 0) {
            List<Map<String, Object>> data = (List<Map<String, Object>>) result.get("data");
            return new Result<List<Map<String, Object>>>().ok(data);
        } else {
            return new Result<List<Map<String, Object>>>().error((String) result.get("msg"));
        }
    }

    /**
     * 按照赛事生成选手荣誉证书编号
     * @param params
     * @param
     * @return
     * @throws Exception
     */
    @GetMapping("createCertificateNoAll")
    public Result<List<Map<String,Object>>> createCertificateNoAll(@ApiIgnore @RequestParam Map<String, Object> params) throws Exception {
        String matchId = (String)params.get("matchId");
        List<Map<String,Object>> list = spMatchItemTeamService.queryAllItemGroup(Long.parseLong(matchId));
        Map<String, Object> paramsNew = new HashMap<>();
        for(Map<String,Object> map : list){
            paramsNew = new HashMap<>();
            paramsNew.put("groupId", map.get("group_id") + "");
            paramsNew.put("matchItemId", map.get("match_item_id") + "");
            spMatchItemTeamService.createCertificateNo(paramsNew);
        }
        return new Result<List<Map<String,Object>>>().ok(null);
    }


    /**
     * 生成指导老师荣誉证书编号
     * @param params
     * @return
     * @throws Exception
     */
    @GetMapping("createCertificateNoTeacher")
    @LogOperation("生成指导老师荣誉证书编号")
    public Result<List<Map<String,Object>>> createCertificateNoTeacher(@ApiIgnore @RequestParam Map<String, Object> params) throws Exception{
        List<Map<String,Object>> list = spMatchItemTeamService.createCertificateNoTeacher(params);
        return new Result<List<Map<String,Object>>>().ok(list);
    }

    /**
     * 生成指导老师荣誉证书编号-全部
     * @param params
     * @return
     * @throws Exception
     */
    @GetMapping("createCertificateNoTeacherAll")
    @LogOperation("生成指导老师荣誉证书编号-全部")
    public Result<List<Map<String,Object>>> createCertificateNoTeacherAll(@ApiIgnore @RequestParam Map<String, Object> params) throws Exception{
        String matchId = (String)params.get("matchId");
        List<Map<String,Object>> list = spMatchItemTeamService.queryAllItemGroup(Long.parseLong(matchId));
        Map<String, Object> paramsNew = new HashMap<>();
        for(Map<String,Object> map : list){
            paramsNew = new HashMap<>();
            paramsNew.put("groupId", map.get("group_id") + "");
            paramsNew.put("matchItemId", map.get("match_item_id") + "");
            spMatchItemTeamService.createCertificateNoTeacher(paramsNew);
        }
        return new Result<List<Map<String,Object>>>().ok(null);
    }

    /**
     * 生成指导老师荣誉证书图片
     * @param params
     * @return
     */
    @GetMapping("certificateTeacher")
    @LogOperation("生成指导老师荣誉证书图片")
    public Result certificateTeacher(@RequestParam Map<String, Object> params){
        spMatchItemTeamService.certificateTeacher(params);
        return new Result().ok("生成成功");
    }

    /**
     * 生成指导老师荣誉证书图片-全部
     * @param params
     * @return
     */
    @GetMapping("certificateTeacherAll")
    @LogOperation("生成指导老师荣誉证书图片-全部")
    public Result certificateTeacherAll(@RequestParam Map<String, Object> params){
        String matchId = (String)params.get("matchId");
        List<Map<String,Object>> list = spMatchItemTeamService.queryAllItemGroup(Long.parseLong(matchId));
        Map<String, Object> paramsNew = new HashMap<>();
        for(Map<String,Object> map : list) {
            paramsNew = new HashMap<>();
            paramsNew.put("groupId", map.get("group_id") + "");
            paramsNew.put("matchItemId", map.get("match_item_id") + "");
            spMatchItemTeamService.certificateTeacher(paramsNew);
        }
        return new Result().ok("生成成功");
    }

    //赛事成绩-队伍
    @GetMapping("signRecordTeam")
    @LogOperation("赛事成绩-队伍")
    public Result<PageData<Map>> signRecordTeam(@ApiIgnore @RequestParam Map<String, Object> params){
        PageData<Map> page = spMatchItemTeamService.signRecordTeam(params);
        return new Result<PageData<Map>>().ok(page);
    }

    /**
     * 导出团体
     * @param params
     * @param response
     * @throws Exception
     */
    @GetMapping("signRecordExport")
    @LogOperation("导出团体")
    public void signRecordExport(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
        params.put("page", "1");
        params.put("limit", "20000");
        PageData<Map> page = spMatchItemTeamService.signRecordTeam(params);
        List<Map> list = page.getList();
        List<SpSignRecordGroupExcel> listExcel = new ArrayList<>();
        SpSignRecordGroupExcel excel = null;
        for(Map map : list){
            excel = new SpSignRecordGroupExcel();
            excel.setId((Long)map.get("id")+"");
            excel.setTeamName((String)map.get("teamName"));
            excel.setPhone((String)map.get("phone"));
            excel.setGroupName((String)map.get("groupName"));
            excel.setRealName((String)map.get("realName"));
            excel.setTicket((String)map.get("ticket"));
            excel.setScore((String)map.get("score"));
            String score1 = (String)map.get("score1");
            excel.setScore1(score1);
            if(StringUtils.isNotBlank(score1)) {
                excel.setTime(score1.replace(".","\""));
            }
            excel.setScore2((String)map.get("score2"));
            excel.setRanks(map.get("ranks")!=null?(Integer)map.get("ranks")+"":"");
            excel.setGrade((String)map.get("grade"));
            excel.setTeacher((String)map.get("teacher"));
            excel.setRemark((String)map.get("remark"));
            excel.setLeader((String)map.get("leader"));
            excel.setSort((Integer)map.get("sort") + "");
            int status = (Integer)map.get("status");
            if(status == 0){
                excel.setStatus("审核中");
            }else if(status == 1){
                excel.setStatus("报名成功");
            } else if (status==2) {
                excel.setStatus("完赛");
            }
            listExcel.add(excel);
        }
        String fileName = (String)params.get("fileName");
        fileName +=  "-" + DateUtils.format(new Date(), "MMdd");
        fileName += "-" + list.size();
        ExcelUtils.exportExcelToTarget(response, fileName, "赛事成绩", listExcel, SpSignRecordGroupExcel.class);
    }

    //赛事成绩-选手
    @GetMapping("signRecordStudent")
    public Result<PageData<Map>> signRecordStudent(@ApiIgnore @RequestParam Map<String, Object> params){
        PageData<Map> page = spMatchItemTeamService.signRecordStudent(params);
        return new Result<PageData<Map>>().ok(page);
    }

    /**
     * 个人赛名次排序
     * @param params
     * @return
     */
    @GetMapping("ranksSortSingle")
    public Result<Map> ranksSortranksSortSingle(@ApiIgnore @RequestParam Map<String, Object> params){
        spMatchItemTeamService.ranksSortSingle(params);
        return new Result<Map>().ok(null);
    }

    /**
     * 编程挑战赛
     * @param params
     * @return
     */
    @GetMapping("ranksSortSingleProgram")
    public Result<Map> ranksSortSingleProgram(@ApiIgnore @RequestParam Map<String, Object> params){
        spMatchItemTeamService.ranksSortSingleProgram(params);
        return new Result<Map>().ok(null);
    }



    /**
     * 团体赛名次排序
     * @param params
     * @return
     */
    @GetMapping("ranksSortTeam")
    public Result<Map> ranksSortTeam(@ApiIgnore @RequestParam Map<String, Object> params){
        spMatchItemTeamService.ranksSortTeam(params);
        return new Result<Map>().ok(null);
    }

    /**
     * 蜂群舞蹈
     * @param params
     * @return
     */
    @GetMapping("ranksSortTeamFqwd")
    public Result<Map> ranksSortTeamFqwd(@ApiIgnore @RequestParam Map<String, Object> params){
        spMatchItemTeamService.ranksSortTeamFqwd(params);
        return new Result<Map>().ok(null);
    }

    /**
     * 导出个人赛
     * @param params
     * @param response
     * @throws Exception
     */
    @GetMapping("exportStudent")
    @LogOperation("导出个人赛")
    public void exportStudent(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
        params.put("page", "1");
        params.put("limit", "20000");
        PageData<Map> page = spMatchItemTeamService.signRecordStudent(params);
        List<Map> list = page.getList();
        List<SpSignRecordStudentExcel> listExcel = new ArrayList<>();
        SpSignRecordStudentExcel excel = null;
        String score00 = "";
        String score11 = "";
        for(Map map : list){
            excel = new SpSignRecordStudentExcel();
            excel.setId((Long)map.get("id")+"");
            excel.setTeamName((String)map.get("teamName"));
            excel.setPhone((String)map.get("phone"));
            excel.setRealName((String)map.get("realName"));
            excel.setTicket((String)map.get("ticket"));
            excel.setCompany((String)map.get("company"));
            excel.setRemark((String)map.get("remark"));
            score00 = (String)map.get("score00");
            if(StringUtils.isNotBlank(score00) && !"null".equals(score00)) {
                excel.setScore((String)map.get("score")  + "/" + score00);
            }else{
                excel.setScore((String)map.get("score"));
            }
            score11 = (String)map.get("score11");
            if(StringUtils.isNotBlank(score11) && !"null".equals(score11)) {
                excel.setScore1((String)map.get("score1") + "/" + score11);
            }else{
                excel.setScore1((String)map.get("score1"));
            }
            // 转换格式
            String oldScore1 = excel.getScore1();
            if(StringUtils.isNotBlank(oldScore1)) {
                excel.setTime(oldScore1.replace(".","\""));
            }
            excel.setScore2((String)map.get("score2"));
            excel.setRanks(map.get("ranks")!=null?(Integer)map.get("ranks")+"":"");
            excel.setGrade((String)map.get("grade"));
            excel.setCertificate((String)map.get("certificate"));
            excel.setLeader((String)map.get("leader"));
            List<Map<String,Object>> teacherList = spMatchItemTeamService.queryTeacherByMatchItemTeamId((Long)map.get("matchItemTeamId"));
            String teacher = "";
            for(Map<String,Object> teacherMap : teacherList){
                teacher += teacherMap.get("realName") + "、";
            }
            if(teacher.length()>0){
                teacher = teacher.substring(0, teacher.length()-1);
            }
            excel.setTeacher(teacher);
            int status = (Integer)map.get("status");
            if(status == 0){
                excel.setStatus("审核中");
            }else if(status == 1){
                excel.setStatus("报名成功");
            } else if (status==2) {
                excel.setStatus("完赛");
            }
            listExcel.add(excel);
        }
        String fileName = (String)params.get("fileName");
        fileName +=  "-" + DateUtils.format(new Date(), "MMdd");
        fileName += "-" + list.size();
        ExcelUtils.exportExcelToTarget(response, fileName, "赛事成绩", listExcel, SpSignRecordStudentExcel.class);
    }

    /**
     * 清除所有成绩
     * @param params
     * @return
     */
    @GetMapping("clearAllScore")
    public Result<PageData<Map>> clearAllScore(@ApiIgnore @RequestParam Map<String, Object> params){
        params.put("page", "1");
        params.put("limit", "20000");
        String type = (String) params.get("type");
        PageData<Map> page = null;
        if("1".equals(type)) {
            page = spMatchItemTeamService.signRecordStudent(params);
        }else if ("2".equals(type)){
            page = spMatchItemTeamService.signRecordTeam(params);
        }
        List<Map> list = page.getList();
        for(Map map : list){
            spMatchItemTeamService.cancleRanks((Long)map.get("matchItemTeamId"));
        }
        return new Result<PageData<Map>>().ok(page);
    }

    //赛事成绩-指导老师
    @GetMapping("signRecordTeacher")
    public Result<PageData<Map>> signRecordTeacher(@ApiIgnore @RequestParam Map<String, Object> params){
        PageData<Map> page = spMatchItemTeamService.signRecordTeacher(params);
        return new Result<PageData<Map>>().ok(page);
    }

    /**
     * 导出指导老师
     * @param params
     * @param response
     * @throws Exception
     */
    @GetMapping("exportSignRecordTeacher")
    @LogOperation("导出指导老师")
    public void exportSignRecordTeacher(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
        params.put("page", "1");
        params.put("limit", "20000");
        PageData<Map> page = spMatchItemTeamService.exportTeacher(params);
        List<Map> list = page.getList();
        List<SpSignRecordTeacherExcel> listExcel = new ArrayList<>();
        for (Map map : list) {
            SpSignRecordTeacherExcel excel = new SpSignRecordTeacherExcel();
            BeanUtil.fillBeanWithMap(map, excel, true);
            listExcel.add(excel);
        }
        // 获取赛事、赛项名字
        String matchName = (String) params.get("matchName");
        String matchItemName = (String) params.get("matchItemName");
        //获取日期
        String date = DateUtils.format(new Date(), "MMdd");
        ExcelUtils.exportExcelToTarget(response, matchName+"-" + matchItemName + "-指导老师-"+date+"-" + list.size(), "指导老师", listExcel, SpSignRecordTeacherExcel.class);
    }


    /**
     * 结束抽签
     * @param id  match_item_id
     * @return
     */
    @GetMapping("endDraw")
    @LogOperation("结束抽签")
    public Result endDraw(@RequestParam Long id, Long groupId){
        return spMatchItemTeamService.endDraw(id, groupId);
    }

    /**
     * 重新抽签
     * @param id  match_item_id
     * @return
     */
    @GetMapping("reDraw")
    @LogOperation("重新抽签")
    public Result reDraw(@RequestParam Long id, Long groupId){
        return spMatchItemTeamService.reDraw(id, groupId);
    }


    @GetMapping("exportCerLog")
    @ApiOperation("分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = Constant.PAGE, value = "当前页码，从1开始", paramType = "query", required = true, dataType="int") ,
            @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
            @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
            @ApiImplicitParam(name = Constant.ORDER, value = "排序方式，可选值(asc、desc)", paramType = "query", dataType="String")
    })
    public Result<PageData<Map>> exportCerLog(@ApiIgnore @RequestParam Map<String, Object> params){
        PageData<Map> page = spMatchItemTeamService.exportCerLog(params);

        return new Result<PageData<Map>>().ok(page);
    }

    /**
     * exportCerLog
     * @param params
     * @param response
     * @throws Exception
     */
    @GetMapping("exportCerLogExcel")
    @LogOperation("导出获奖情况")
    public void exportCerLogExcel(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
        params.put("page", "1");
        params.put("limit", "20000");
        PageData<Map> page = spMatchItemTeamService.exportCerLog(params);
        List<Map> list = page.getList();
        List<SpCerLogExcel> listExcel = new ArrayList<>();
        SpCerLogExcel excel = null;
        for(Map map : list){
            excel = new SpCerLogExcel();
            excel.setTeamName((String)map.get("teamName"));
            excel.setCompany((String)map.get("company"));
            excel.setLeaderName((String)map.get("leader"));
            excel.setLeaderPhone((String)map.get("phone"));
            excel.setMatchItemName((String)map.get("itemName"));
            excel.setGroupType((String)map.get("groupType"));
            excel.setGroupName((String)map.get("groupName"));
            excel.setRealName((String)map.get("realName"));
            excel.setTeacher((String)map.get("teacher"));
            excel.setRanks(map.get("ranks")!=null?(Integer)map.get("ranks")+"":"");
            excel.setGrade((String)map.get("grade"));
            listExcel.add(excel);
        }
        String fileName = (String)params.get("matchId");
        fileName += "-" + (String)params.get("province");
        fileName +=  "-" + DateUtils.format(new Date(), "MMdd");
        fileName += "-" + list.size();
        ExcelUtils.exportExcelToTarget(response, fileName, "获奖情况", listExcel, SpCerLogExcel.class);
    }

    //清除成绩
    @PostMapping("cancleScore")
    @LogOperation("清除成绩")
    public Result cancleScore(@RequestBody SpMatchItemTeamDTO dto){
        spMatchItemTeamService.cancleScore(dto.getId());
        return new Result();
    }

    //清楚个人成绩
    @PostMapping("cancleScoreStudent")
    @LogOperation("清除个人成绩")
    public Result cancleScoreStudent(@RequestBody SpMatchItemTeamUserDTO dto){
        spMatchItemTeamService.cancleUserScore(dto.getId());
        return new Result();
    }

    /**
     * 导出完赛表单 exportFinish
     * @param params
     * @return
     */
    @GetMapping("exportFinish")
    public void exportFinish(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
        params.put("page", "1");
        params.put("limit", "20000");
        String type = (String)params.get("type");
        if(!"all".equals(type)){
            params.put("status", 2);
        }
        PageData<Map> page = spMatchItemTeamService.signRecordStudent(params);
        List<Map> list = page.getList();
        List<SpFinishExcel> listExcel = new ArrayList<>();
        SpFinishExcel excel = null;
        String matchName = "";
        for (Map map : list) {
            excel = new SpFinishExcel();
            excel.setId((Long) map.get("id") + "");
            excel.setMatchName((String) map.get("matchName"));
            excel.setItem((String) map.get("item"));
            excel.setTeamName((String) map.get("teamName"));
            excel.setGroupName((String) map.get("groupName"));
            excel.setDictLabel((String) map.get("dictLabel"));
            excel.setRealName((String) map.get("realName"));
            excel.setLeaderName((String) map.get("leader"));
            excel.setTicket((String) map.get("ticket"));
            excel.setCompany((String) map.get("company"));
            excel.setGrade((String) map.get("grade"));
            excel.setCertificateNo((String) map.get("certificate"));
            excel.setTeacher((String) map.get("teacher"));
            excel.setIdCard((String) map.get("idCard"));
            int status = (Integer) map.get("status");
            int isRise = (Integer) map.get("isRise");
            String rejectReason = (String) map.get("rejectReason");
            if (status == 1){
                excel.setStatus("报名成功");
            }
            else if (status == 2) {
                if (isRise == 1) {
                    excel.setStatus("已确认晋级");
                } else {
                    excel.setStatus("完赛");
                }
            }
            else if (status == 4) {
                excel.setStatus("比赛中");
            }
            else if (status == 5) {
                if("放弃晋级".equals(rejectReason)) {
                    excel.setStatus("放弃晋级");
                }else{
                    excel.setStatus("已获晋级资格");
                }
            }
            else if (status == 6) {
                excel.setStatus("晋级成功");
            } else if (status == 7) {
                excel.setStatus("弃权");
            } else if (status == 8) {
                excel.setStatus("驳回");
            } else if (status == 9) {
                excel.setStatus("待确认");
            } else if (status == 10) {
                excel.setStatus("报名未成功");
            }
            listExcel.add(excel);
            matchName = (String) map.get("matchName");
        }
        String fileName = matchName;
        fileName += "-" + DateUtils.format(new Date(), "MMdd");
        fileName += "-" + list.size();
        ExcelUtils.exportExcelToTarget(response, fileName, "赛事成绩", listExcel, SpFinishExcel.class);
    }

    /**
     * 修改成绩
     */


    /**
     导入功能：
     1、直报证书
        菜单：业务菜单-直报证书
        逻辑：线下的赛事活动收集的表格直接导入, 直接通过证书页面查询
        代码： SpMatchItemTeamController.importCertificate
        页面：

     2、上传晋级 （个人赛和团体赛）
        菜单：业务菜单-赛事管理-点击赛事名称-上传晋级
        逻辑：excel配置的当前赛事信息，导入时直接导入到上级赛事中
        代码：
            SpMatchItemTeamController.importPormotion --导入
            SpMatchItemTeamController.exportError1    --导出失败原因
        页面：

     3、赛事成绩导入
        菜单：业务菜单-赛事管理-点击赛事名称-点击赛事管理-赛项详情点击查看-导入证书
        逻辑：
            ① 导出记录：点击导出记录   代码： SpMatchItemTeamController.export
            ② 导入成绩：根据导出记录，录入时间、成绩、名次、证书编号（自动生成）
                    代码：
                        SpMatchItemTeamController.importMatchScore --导入
                        SpMatchItemTeamController.exportError2     --导出失败原因
                    页面:

            ③ 生成证书编号

            ④ 生成证书图片：点击生成证书图片
                代码： SpMatchItemTeamController.certificate
                页面：


     4、下载获奖证书
        菜单：业务菜单-下载证书-点击赛事名称-点击获奖证书-下载全部
        代码： SpMatchItemTeamController.exportMatchScoreError
        页面： spmatchitemrecord.vue

     5、 导入底图功能
        包括： 选手参赛证件、领队参赛证件、选手号码布、选手获奖证书、老师荣誉证书 的底图，都挂在赛事上，底图能查看能修改；

        老师荣誉证书

     */

}

